<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
{insert name="module_cssjs" css="core.css" js="jquery.min.js;jquery.area.js"}
</head>
{literal}
<script type="text/javascript">
$(document).ready(function() {
$('[name="del"]').click(function() {
	var $this = this;
	var nodeId = $(this).parents('tr').attr('node-id');
	if(!nodeId) {
		alert('缺少参数');return ;
	}
	if(!confirm('您确定删除此景点吗？'))return ;
	
	var params = {'id': nodeId};
	$.post('/yunying/product/del.json', params, function(dt) {
		if(dt.status) {
			alert(dt.message);
		} else {
			$($this).parents('tr').remove();
		}
	}, 'json');
});

$('[name="status"]').click(function() {
	var status = $(this).attr('status');
	var id = $(this).attr('id');
	var act = $(this).attr('act');
	if(!id) {
		alert('未知景点ID');return ;
	}
	var params = {status: status, id: id};
	if(act) params.act = act;
	$.post('/yunying/product/status.json', params, function(dt) {
		if(dt.status) {
			alert(dt.message);
		} else {
			alert('更改景点状态成功');
			window.location.href=window.location.href;
		}
	}, 'json');
});
})
</script>
{/literal}
<body>
<h3 class="label">
	<strong class="on"><span>所有景点</span></strong>
	<strong><span><a href="/yunying/product/add">添加景点</a></span></strong>
	<span class="refresh"><a href="">刷新</a></span>
</h3>
<div class="search">
	<form action="">
	<span>景点名： <input name="name" value="{$name}" /></span>
	<span>所在地：
	<select class="selectInput" name="province" id="province">
		<option value="{$province}"></option>
	</select>
	<select class="selectInput" name="city" id="city">
		<option value="{$city}"></option>
	</select>
	{literal}<script type="text/javascript">$.provinceCity('province', 'city');</script>{/literal}
	</span>
	<span><label>热门： <select name="hot"><option value="">不限</option><option {if $hot}selected="selected"{/if} value="1">热门</option></select></label></span>
	<span><label>推荐： <select name="recommend"><option value="">不限</option><option {if $recommend}selected="selected"{/if} value="1">推荐</option></select></label></span>
	<input value="搜索" type="submit" />
	</form>
</div>
<div class="table">
	<table class="TB-list">
		<tr class="TB-header">
			<td width="50">景点ID</td>
			<td width="150">景点名称</td>
			<td width="150">所属分类</td>
			<td>地址</td>
			<td width="500">操作</td>
		</tr>
		{foreach item=item key=key from=$product.data name=list}
		<tr {if $smarty.foreach.list.index%2 == 0}class="even"{else}class="odd"{/if} node-id={$item.id}>
			<td>{$item.id}</td>
			<td>{$item.name}</td>
			<td>{$item.category.name}</td>
			<td>{$item.province|intToProvinceName} {$item.city|intToCityName:$item.province} {$item.location}</td>
			<td>
				[<a href="{$_conf.server}/deal/{$item.id}.html" target="_blank">查看</a>]
				[<a href="/yunying/product/edit?id={$item.id}">编辑</a>]
				{if $item.status == 1}
				[<a name="status" status="0" id="{$item.id}" href="javascript:void(0);">下架</a>]
				{else}
				[<a name="status" status="1" id="{$item.id}" href="javascript:void(0);">上架</a>]
				{/if}
				{if $item.hot == 1}
				[<a name="status" status="0" act="hot" id="{$item.id}" href="javascript:void(0);">取消热门</a>]
				{else}
				[<a name="status" status="1" act="hot" id="{$item.id}" href="javascript:void(0);">设为热门</a>]
				{/if}
				{if $item.recommend == 1}
				[<a name="status" status="0" act="recommend" id="{$item.id}" href="javascript:void(0);">取消推荐</a>]
				{else}
				[<a name="status" status="1" act="recommend" id="{$item.id}" href="javascript:void(0);">设为推荐</a>]
				{/if}
				[<a href="{$_conf.server}/product/{$item.id}.html" target="_blank">查看</a>]
				[<a href="/yunying/product/picture/?id={$item.id}">景点图片</a>]
				[<a href="/yunying/product/ticket/?id={$item.id}">门票管理</a>]
				[<a href="javascript:void(0);" name="del">删除</a>]</td>
		</tr>
		{/foreach}
	</table>
	<div>{insert name="module_page" query=$query size=$product.size num=$product.num page=$product.page}</div>
</div>
</body>
</html>